package com.dy.controller;

import com.dy.bean.Sugar;
import com.dy.service.SugarService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @projectName: day0604
 * @package: com.dy.controller
 * @className: SugarController
 * @author: DuanYu
 * @description: TODO
 * @date: 2024/6/4 20:21
 * @version: 1.0
 */
@RestController
public class SugarController {
    @Autowired
    SugarService service;
    @RequestMapping("/listtwo")
    public Map showTwo(){
        List<Sugar> sugars = service.showTwo();
        return SugarUtil.getPieData(sugars);
    }
    @RequestMapping("/listpp")
    public Map showPp(){
        List<Sugar> sugars = service.showPp();
        return SugarUtil.getBarData(sugars);
    }
    @RequestMapping("/listmap")
    public Map showMap(){
        List<Sugar> sugars = service.showMap();
        return SugarUtil.getMapData(sugars);
    }
    @RequestMapping("listsum")
    public Map showSum(){
        Double aDouble = service.showSum();
        Map map = new HashMap<>();
        map.put("status",0);
        map.put("data",aDouble);
        return map;
    }
    @RequestMapping("listspu")
    public String showSpu(){
        List<Sugar> sugars = service.showSpu();
        List list = new ArrayList<>();
        list.add("spu名称");
        list.add("金额");
        return SugarUtil.getTablePlayData(list,sugars);
    }
}
